Skip to content

correct to use actual xoshiro128++ implementation#1210

Open
corwinkuiper wants to merge 1 commit into
agbrs:masterfrom
corwinkuiper:xoshiro128plusplus
Open

correct to use actual xoshiro128++ implementation#1210
corwinkuiper wants to merge 1 commit into
agbrs:masterfrom
corwinkuiper:xoshiro128plusplus

Conversation

@corwinkuiper

Copy link
Copy Markdown
Member

During transcription there appears to be an error that was introduced such that we ended up using some strange combination of xoshiro128++ and xoshiro128**. This corrects it to use xoshiro128++.

Here is the original C implementation:

static inline uint32_t rotl(const uint32_t x, int k) {
	return (x << k) | (x >> (32 - k));
}


static uint32_t s[4];

uint32_t next(void) {
	const uint32_t result = rotl(s[0] + s[3], 7) + s[0];

	const uint32_t t = s[1] << 9;

	s[2] ^= s[0];
	s[3] ^= s[1];
	s[1] ^= s[2];
	s[0] ^= s[3];

	s[2] ^= t;

	s[3] = rotl(s[3], 11);

	return result;
}

The only error I spotted being that we multiplied by 9 rather than adding s[0] on the first line.

This requires a 0.X bump as we said we wouldn't change this in minor releases (we're still V0, so the third number is considered the minor release).

@corwinkuiper corwinkuiper requested a review from gwilymk June 21, 2026 11:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant